package kr.snake75.action;

import javax.servlet.http.HttpSession;

import kr.snake75.annotation.Controller;
import kr.snake75.annotation.RequestMapping;
import kr.snake75.annotation.RequestParam;
import kr.snake75.annotation.Result;
import kr.snake75.annotation.ResultAttr;
import kr.snake75.user.UserVO;

// /app/user/login

@Controller
public class UserController {

	@RequestMapping("/user/regist")
	public void regist(@RequestParam(value=RequestParam.DTO, classpath="kr.snake75.user.UserVO") UserVO vo) throws Exception {
		System.out.println("regist : " + vo);
	}
	
	@RequestMapping("/user/view")
	@Result(value="/viewUser.jsp")
	public @ResultAttr("user") UserVO view(@RequestParam("id") String id) throws Exception {
		System.out.println("view : " + id);
		
		UserVO vo = new UserVO();
		
		vo.setName("Kim...");
		
		return vo;
	}
	@RequestMapping("/user/login")
	public void login(
					@RequestParam(RequestParam.SESSION) HttpSession session,
					@RequestParam("id") String id,
					@RequestParam("pw") String pw) throws Exception {
		//
		
		session.setAttribute("user", id);
	}
}
